package com.hao_family.atcrowdfunding.controller.permission;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hao_family.atcrowdfunding.beans.TRole;
import com.hao_family.atcrowdfunding.constant.AppConstant;
import com.hao_family.atcrowdfunding.service.RoleService;

@Controller
public class RoleController {
	@Autowired
	RoleService roleService;
	
	/**
	 * 查询角色list
	 * @return
	 */
	@ResponseBody
	@GetMapping("/role/getlist")
	public PageInfo<TRole> getRoleList(Model model,
			@RequestParam(value="condition",defaultValue="")String condition,
			@RequestParam(value="pn",defaultValue="1")Integer pn,
			@RequestParam(value="ps",defaultValue=AppConstant.DEFAULT_PAGE_SIZE)Integer ps,
			HttpSession session) {
		PageHelper.startPage(pn, 3);
		List<TRole> list = roleService.getAllRole();
		PageInfo<TRole> pageInfo = new PageInfo(list, ps);
		return pageInfo;
	}
}
